<%@page import="com.itsm.v17.entity.Zibbix"%>
<%@page import="java.util.LinkedList"%>
<%@page import="org.jfaster.ProxyTemplate"%>
<%@page import="org.jfaster.Template"%>
<%@page import="java.util.List"%>
<%@ page pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String status=request.getParameter("status");
String startDate=request.getParameter("startDate");
String endDate=request.getParameter("endDate");
String message =(String)request.getAttribute("message");
List list =(List)request.getAttribute("list");
if(list==null){list=new LinkedList();}
if(status==null){status="";}
if(startDate==null){startDate="";}
if(endDate==null){endDate="";}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Zibbix数据列表管理</title>
<link href="<%=basePath%>js/DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
<link href="<%=basePath%>css/home.css" type="text/css" rel="stylesheet" />
<script src="<%=basePath%>js/DatePicker/WdatePicker.js" type="text/javascript"></script>
<link href="<%=basePath%>js/DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
<script src="<%=basePath%>itsm/js/ajax.js"></script>
<script src="<%=basePath%>itsm/js/ajax.form.js"></script>
<script src="<%=basePath%>itsm/js/formValidate.js"></script>
<script src="<%=basePath%>itsm/js/select.js"></script>
<script src="<%=basePath%>itsm/js/reSet.js"></script>

<link type="text/css" rel="stylesheet" href="<%=path%>/itsm/PageNavgation/css/PageNavgation.css">
<link type="text/css" rel="stylesheet" href="<%=path%>/itsm/PageNavgation/css/PageNavgation.gray.css">
<script type="text/javascript" src="<%=path%>/itsm/PageNavgation/js/PageNavgation.js"></script>
<script type="text/javascript" src="<%=path%>/itsm/PageNavgation/js/PageNavgation-simple.js"></script>

<style>
.tableblue00 td{
padding:5px;
}
.已阅{
font-color:blue;
color:blue;
}
.bbzxbg2:hover{
background:#dadada;
}
.columnHead td{
background:#e7eaed;
}
.status1{
font-color:blue;
color:blue;
}
.status2{
font-color:gray;
color:gray;
}
</style>
<script>
function query()
{
	var startDate=document.getElementById("startDate").value;
	var endDate=document.getElementById("endDate").value;
	var status=document.getElementById("status").value;
	location.href="<%=path%>/itsm17/zibbix/list?startDate="+startDate+"&endDate="+endDate+"&status="+status;
}
</script>
</head>
<body style="padding:5px;margin:0px;">
	    <table width="100%" cellspacing="1" cellpadding="0" border="0" bgcolor="#D6E6F4" class="tableblue00">
                            <tbody>
                            <tr class="bbzxbg2">
                              <td colspan=3 >
                              	  状态:
                              	  <select id="status" name="status" >
                              	  	<option value="" <%if("".equals(status)){out.print("selected='selected'");} %> >全部</option>
                              	  	<option value="0" <%if("0".equals(status)){out.print("selected='selected'");} %>>未处理</option>
                              	 	<option value="1" <%if("1".equals(status)){out.print("selected='selected'");} %>>已处理</option>
                              	 	<option value="2" <%if("2".equals(status)){out.print("selected='selected'");} %>>不处理</option>
                              	 </select>
                              	 &nbsp; &nbsp; &nbsp; &nbsp;
                              	 起点时间： <input type="text" id="startDate" value="<%=startDate%>"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                              	 &nbsp; &nbsp; &nbsp; &nbsp;
                              	 截止时间： <input type="text" id="endDate" value="<%=endDate%>" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                              	 &nbsp; &nbsp; &nbsp; &nbsp;
                              	 
                              	 <a class="actionbutton"  href='javascript:;' onclick="query()" class="menudiv" style="margin-right: 10px;">查询</a>
                              	 &nbsp;&nbsp;&nbsp; &nbsp;
                              	 <a class="actionbutton"  href='javascript:window.location.reload();' class="menudiv" style="margin-right: 10px;">刷新</a>
                              	 &nbsp;&nbsp;&nbsp; &nbsp;
                              	 
                              	 <span ><%=message%></span>
   	
                              </td>
                            </tr></tbody>
          </table>
                     <br/>
                     
<table width="100%" cellspacing="1" cellpadding="0" border="0" bgcolor="#D6E6F4" class="tableblue00 ry_box" id="datalist" >
   <tbody>
   <tr class="columnHead" align="center" >
                <td >序号</td>
                <td align="left">标题</td>
                <td align="left">时间</td>
                <td align="left">状态</td>
                <td align="left">工单号</td>
                <%--<td align="left">发送人</td> --%>
                <td align="left">操作</td>
         </tr>
         
   <%
   try
   {
	   for(int i=0;i<list.size();i++)
  		{
  			Zibbix zibbix=(Zibbix)list.get(i);
  			%>
  				<tr class="bbzxbg2">
  				<td><%=(i+1)%></td>
  				<td align="left"><a href="<%=path%>/itsm17/zabbix/detail?id=<%=zibbix.getId()%>"><%=zibbix.getTitle()%></a></td>
               <td><%=zibbix.getSendTime()%></td>
               <td align="left" ><font class="status<%=zibbix.getStatu()%>"><%
               if("0".equalsIgnoreCase(zibbix.getStatu())){out.print("未处理");}
               else if("1".equalsIgnoreCase(zibbix.getStatu())){out.print("已处理");}
               else {out.print("不处理");}
               %></font></td>
               <td align="left"><a href="<%=path%>/itsm17/zibbix/openFlow?serialNo=<%=zibbix.getSerialNo()%>" target="_blank"><%=zibbix.getSerialNo()%></a></td>
              <%-- <td align="left"><%=zibbix.getFromUser()%></td> --%>
               <td align="left">
               	<%
               		if("0".equals(zibbix.getStatu()))
               		{
               			%>
               				<a href="javascript:;" onclick="transEvent('<%=zibbix.getId()%>','<%=zibbix.getTitle()%>',this)" >转事件</a>
               	  &nbsp;&nbsp;&nbsp;&nbsp;
               	  <a href="javascript:;" onclick="setUnhandle('<%=zibbix.getId()%>','<%=zibbix.getTitle()%>',this)" >不处理</a>
               	  &nbsp;&nbsp;&nbsp;&nbsp;
               	  <a href="javascript:;" onclick="deleteZibbix('<%=zibbix.getId()%>','<%=zibbix.getTitle()%>',this)" >删除</a>
               			<%
               		}
               	%>
               	 &nbsp;
               </td>
        </tr>
  			<%
  		}
	   if(list.size()==0)
	   {
		   out.println("<tr><td colspan=6>无内容</td></tr>");
	   }
   }catch(Exception exception)
   {
	   exception.printStackTrace();
	   out.println("<tr><td colspan=6>"+exception.toString()+"</td></tr>");
   }
   %>
                     
 </tbody>
</table>
<br/>
<div class="page mt10">
         <div class="pagination" id="pagination" ></div>
</div>  <br/>  
                                
<script>
var isRunning=false,tempObject,tempText;
/**
 * <a href="/mailevent/MailEventAction!tranEvent.do?messageid=c28ef71d68214952a20d01095200a72f" class="actionbutton">转事件</a>
 */
function transEvent(id,title,obj)
{
	tempObject=obj;
	tempText=obj.innerHTML;
	if(confirm("确定转换为事件？"+title))
	{
		//obj.innerHTML='正在跳转...';
		//location.href="/mailevent/MailEventAction!tranEvent.do?id="+id+"&type=zibbix";
		window.open("/mailevent/MailEventAction!tranEvent.do?id="+id+"&type=zibbix","_blank");
	}
}
function setUnhandle(id,title,obj)
{
	tempObject=obj;
	tempText=obj.innerHTML;
	if(isRunning){alert("操作正在进行，请稍等...");return;}
	if(confirm("确定设置不处理？"+title))
	{
		var args="id="+id;
		obj.innerHTML='稍等...';
		isRunning=true;
		new ajax({'url':'<%=path%>/itsm17/zibbix/setUnhandle','params':args,'success':function(data)
		{
			var json=toJson(data);
			if(json.result == true)
			{
				window.location.reload();
			}else
			{
				isRunning=false;
				tempObject.innerHTML=tempText;
				alert("发生错误："+json.message);
			}
		}});	
	}
}
function deleteZibbix(id,title,obj)
{
	tempObject=obj;
	tempText=obj.innerHTML;
	if(isRunning){alert("操作正在进行，请稍等...");return;}
	if(confirm("确定删除？"+title))
	{
		var args="id="+id;
		obj.innerHTML='稍等...';
		isRunning=true;
		new ajax({'url':'<%=path%>/itsm17/zibbix/delete','params':args,'success':function(data)
		{
			var json=toJson(data);
			if(json.result == true)
			{
				window.location.reload();
			}else
			{
				isRunning=false;
				tempObject.innerHTML=tempText;
				alert("发生错误："+json.message);
			}
		}});	
	}
	
}

var start=<%=request.getAttribute("start")%>;
var size=<%=request.getAttribute("size")%>;
var count=<%=request.getAttribute("count")%>;
var currentPage=(start/size)+1;
function pageNavCall(index)
{
	//alert(index);
	var tempStart=(index-1)*size;
	var args="start="+tempStart+"&size="+size;
	var startDate=document.getElementById("startDate").value;
	var endDate=document.getElementById("endDate").value;
	var status=document.getElementById("status").value;
	location.href="<%=path%>/itsm17/zibbix/list?startDate="+startDate+"&endDate="+endDate+"&status="+status+"&"+args;
}
var pageNav=new PageNavgation();
pageNav.setHandle(pageNav);
pageNav.setCall(pageNavCall);
pageNav.setAllCount(count);
pageNav.setPageSize(size);
pageNav.setCurrentPage(currentPage);
pageNav.bind("pagination");
</script>

</body>
</html>